package com.example.paopao.consumer.job.dao.persist.repository.impl;

import com.example.paopao.common.pojo.vo.PageData;
import com.example.paopao.common.util.PageInfoToPageDataConverter;
import com.example.paopao.consumer.job.dao.persist.mapper.DistrictMapper;
import com.example.paopao.consumer.job.dao.persist.mapper.JobHiringMapper;
import com.example.paopao.consumer.job.dao.persist.repository.IJobHiringRepository;
import com.example.paopao.consumer.job.pojo.vo.DistrictInfoVo;
import com.example.paopao.consumer.job.pojo.vo.JobHringVO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class IJobHiringRepositoryImpl implements IJobHiringRepository {
    @Autowired
    private JobHiringMapper jobHiringMapper;

    @Autowired
    private DistrictMapper districtMapper;

    @Override
    public List<JobHringVO> listJobHiring( Integer pageNum, Integer pageSize) {
        List<JobHringVO> jobHringVOS = jobHiringMapper.listJobHiring();
        List<DistrictInfoVo> districtList = districtMapper.getDistrictList();
        for (JobHringVO jobHringVO : jobHringVOS) {
            for (DistrictInfoVo districtInfoVo : districtList) {
                long city = jobHringVO.getCity();
                int id = districtInfoVo.getId();
                Long classifyId = jobHringVO.getClassifyId();
                if (city==id) {
                    jobHringVO.setCityName(districtInfoVo.getDistrict());
                }
                if (classifyId==id) {
                    jobHringVO.setClassfiy(districtInfoVo.getDistrict());
                }
            }
        }

        return jobHringVOS;
//        PageHelper.startPage(pageNum,pageSize);
//        PageInfo<JobHringVO> pageInfo=new PageInfo<>(jobHringVOS);
//        return PageInfoToPageDataConverter.convert(pageInfo);
    }

}
